#include "CMoves.h"
#include <iostream>

CMoves::CMoves()
{
    c_sync = new CSync;
}


CMoves::~CMoves()
{
    delete c_sync;
}


void CMoves::get_moves(QTcpSocket *socket)
{
    CNetwork::get_instance()->clients[socket]->set_direction(CNetwork::get_instance()->receive(socket));
    CNetwork::get_instance()->clients[socket]->set_x(CNetwork::get_instance()->receive(socket));
    CNetwork::get_instance()->clients[socket]->set_y(CNetwork::get_instance()->receive(socket));
    //CNetwork::get_instance()->select_action(socket);
    emit move(socket);
    std::cout << CNetwork::get_instance()->clients[socket]->get_id().toStdString() << " va a la position ( " << CNetwork::get_instance()->clients[socket]->get_x().toStdString() << ";" <<  CNetwork::get_instance()->clients[socket]->get_y().toStdString() << " )"<< std::endl;

    for(int i = 0; i < 3; i++)
    {
        CNetwork::get_instance()->select_action(socket);
    }

    c_sync->synchronisation();
}
